<?php
// +----------------------------------------------------------------------
// | EasyAdmin
// +----------------------------------------------------------------------
// | PHP交流群: 763822524
// +----------------------------------------------------------------------
// | 开源协议  https://mit-license.org 
// +----------------------------------------------------------------------
// | github开源项目：https://github.com/zhongshaofa/EasyAdmin
// +----------------------------------------------------------------------
namespace app\model\api;

use laytp\BaseModel;
use think\model\concern\SoftDelete;

class SkySeason extends BaseModel
{
    protected $name = 'sky_season';

    protected $guide = ['先祖信息','季节物品','季节蜡烛','任务详情'];


    /**
     * 季节详情
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail(){
        $detail = $this->where('status','=',1)->cache(true)->find()->toArray();
        $guide_list = json_decode($detail['guide_img'],true);
        array_walk($guide_list,function(&$item) use ($detail){
            $item['textColor'] =  $detail['word_color'];
            $item['value'] =  $detail['season'];
        });

        $return = array(
            'cover'      => $detail['bg_img'],
            'pageBackgroundColor' => $detail['bg_color'],
            'dateTextColor'       => $detail['date_word_color'],
            'dateBackgroundColor' => $detail['date_bg_color'],
            'titleDecoration'     => $detail['tag_icon0'],
            "date"   => date("Y年m月d日",$detail['start_date']).'-'.date("Y年m月d日",$detail['end_date']),
            'navigation' => $guide_list,
            'articles' => array(
                array(
                    'id' => 1,
                    'title' => $detail['tag1'],
                    'titleDecoration' => $detail['tag_icon1'],
                    'richText' => str_replace('%COVER%',$detail['video_cover1'],$detail['content1']),
                ),
                array(
                    'id' => 2,
                    'title' => $detail['tag2'],
                    'titleDecoration' => $detail['tag_icon2'],
                    'richText' => str_replace('%COVER%',$detail['video_cover2'],$detail['content2']),
                ),
                array(
                    'id' => 3,
                    'title' => $detail['tag3'],
                    'titleDecoration' => $detail['tag_icon3'],
                    'richText' => str_replace('%COVER%',$detail['video_cover3'],$detail['content3']),
                ),
                array(
                    'id' => 4,
                    'title' => $detail['tag4'],
                    'titleDecoration' => $detail['tag_icon4'],
                    'richText' => str_replace('%COVER%',$detail['video_cover4'],$detail['content4']),
                ),
                array(
                    'id' => 5,
                    'title' => $detail['tag5'],
                    'titleDecoration' => $detail['tag_icon5'],
                    'richText' => str_replace('%COVER%',$detail['video_cover5'],$detail['content5']),
                )
            )
        );

        return $return;
    }
}